<ui:composition
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:easy="http://easy.widgets.com"
    template="/basic.xhtml">


<ui:define  name="body">
    <a4j:keepAlive beanName="segmentacaoManagedBean" />
    <a4j:form id="form">

        <rich:simpleTogglePanel switchType="client" label="#{rotulo['cadastro_segmentacao']}"
        id="listaSegmentacao">
            <h:panelGrid columns="6">
                    <h:outputText value="#{rotulo['nome']}"/>
                    <h:inputText value="#{segmentacaoManagedBean.segmentacao.nome}" style=" width : 100px;" rendered="#{segmentacaoManagedBean.renderedInputTextTag}"/>
                    <h:outputText value="#{segmentacaoManagedBean.segmentacao.nome}" rendered="#{segmentacaoManagedBean.renderedOutputTextTag}"/>

                    <h:outputText value="#{rotulo['descricao']}"/>
                    <h:inputText value="#{segmentacaoManagedBean.segmentacao.descricao}" style=" width : 170px;"  rendered="#{segmentacaoManagedBean.renderedInputTextTag}"/>
                    <h:outputText value="#{segmentacaoManagedBean.segmentacao.descricao}"  rendered="#{segmentacaoManagedBean.renderedOutputTextTag}"/>

                   <a4j:commandButton value="#{rotulo['adicionar']}" action="#{segmentacaoManagedBean.adicionarSegmentacao}" reRender="listaSegmentacao, form" rendered="#{segmentacaoManagedBean.renderedBotaoAdicionar}"/>
                   <a4j:commandButton value="#{rotulo['salvar']}" action="#{segmentacaoManagedBean.salvarSegmentacao}" reRender="listaSegmentacao, form" rendered="#{segmentacaoManagedBean.renderedBotaoSalvar}"/>                   
                   <a4j:commandButton value="#{rotulo['desfazer']}" action="#{segmentacaoManagedBean.desfazer}" reRender="listaSegmentacao, form" rendered="#{segmentacaoManagedBean.renderedBotaoDesfazer}"/>
                   
            </h:panelGrid>

            <rich:dataTable value="#{segmentacaoManagedBean.listaSegmentacao}" rows="10" var="segmentacao"
                    rendered="#{segmentacaoManagedBean.renderedListaSegmentacao}"
                    onRowMouseOver="this.style.backgroundColor='#F1F1F1'" id="tableListaSegmentacao"
                    onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
                            <f:facet name="header">
                                    <rich:columnGroup>
                                        <rich:column>
                                            #{rotulo['nome']}
                                        </rich:column>
                                        <rich:column>
                                            #{rotulo['descricao']}
                                        </rich:column>
                                        <rich:column>
                                            #{rotulo['visualizar']}
                                        </rich:column>
                                        <rich:column>
                                            #{rotulo['editar']}
                                        </rich:column>
                                        <rich:column>
                                            #{rotulo['excluir']}
                                        </rich:column>
                                    </rich:columnGroup>
                            </f:facet>
                    <rich:column>
                        <h:outputText value="#{segmentacao.nome}"/>
                    </rich:column>
                     <rich:column>
                        <h:outputText value="#{segmentacao.descricao}"/>
                    </rich:column>
                    <rich:column>
                        <div align="center"> <a4j:commandLink action="#{segmentacaoManagedBean.visualizar}" reRender="listaSegmentacao,listaTag,form" value="#{rotulo['tags_vinculadas']}">
                            <f:setPropertyActionListener value="#{segmentacao.listaTag}" target="#{segmentacaoManagedBean.segmentacao.listaTag}"/>
                        </a4j:commandLink> </div>
                    </rich:column>
                     <rich:column>
                       <div align="center"> <a4j:commandLink action="#{segmentacaoManagedBean.editarSegmentacao}" reRender="listaSegmentacao" value="#{rotulo['editar']}">
                            <f:setPropertyActionListener value="#{segmentacao}" target="#{segmentacaoManagedBean.segmentacao}"/>
                        </a4j:commandLink> </div>
                     </rich:column>
                     <rich:column>
                       <div align="center"><a4j:commandLink action="#{segmentacaoManagedBean.excluirSegmentacao}" reRender="listaSegmentacao" value="#{rotulo['excluir']}">
                            <f:setPropertyActionListener value="#{segmentacao}" target="#{segmentacaoManagedBean.segmentacao}"/>
                        </a4j:commandLink> </div>
                     </rich:column>
                </rich:dataTable>

        </rich:simpleTogglePanel>
        <rich:simpleTogglePanel switchType="client" label="#{rotulo['cadastro_tag']}" rendered="#{segmentacaoManagedBean.renderedToggleTag}"
        id="listaTag">
            <h:panelGrid columns="5">
                <easy:inputCamposTag campo1="#{segmentacaoManagedBean.tagInformada.nome}"
                campo2="#{segmentacaoManagedBean.tagInformada.descricao}"/>

                   <a4j:commandButton value="#{rotulo['adicionar']}" action="#{segmentacaoManagedBean.adicionarTag}" reRender="listaTag, form" rendered="#{segmentacaoManagedBean.renderedBotaoAdicionarTag}"/>
                   <a4j:commandButton value="#{rotulo['salvar']}" action="#{segmentacaoManagedBean.salvarTag}" reRender="listaTag, form" rendered="#{segmentacaoManagedBean.renderedBotaoSalvarTag}"/>
            </h:panelGrid>

            <a4j:region rendered="#{segmentacaoManagedBean.renderedListaTag}" >
                <easy:dataTableTag value="#{segmentacaoManagedBean.listaTag}"
                controller="#{segmentacaoManagedBean}"
                tagInformada="#{segmentacaoManagedBean.tagInformada}"
                reRender="listaTag"/>
            </a4j:region>

        </rich:simpleTogglePanel>

    </a4j:form>


</ui:define>

</ui:composition>